<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>UIC iClock</title>

    <script>
      window.onload = getTime; //网页加载完就调用getTime()方法
      var initTime = new Date().getTime(); //记录初始时间
      function getTime() {
        var today = new Date(); //获取当前系统时间
        today = new Date(initTime - (today.getTime() - initTime)); //计算初始时间和当前时间差
        var hours = today.getHours(); //获取小时
        var minutes = today.getMinutes(); //获取分
        var seconds = today.getSeconds(); //获取秒
        if (minutes < 10) {
          //分小于10就在前面补0
          minutes = "0" + minutes;
        }
        if (seconds < 10) {
          //秒小于10就在前面补0
          seconds = "0" + seconds;
        }
        //把时分秒拼起来得到时间
        var time = hours + ":" + minutes + ":" + seconds;
        //把时间显示在div上,您自己可以放在网页任何位置,反正时间就是time
        document.getElementById("div").innerHTML = time;
        //每隔一秒更新一次时间
        setTimeout("getTime()", 1000);
      }
    </script>
  </head>
  <body>
    <div style="text-align: center; margin-top: 80px">
      <img src="img/UIC-logo.jpg" alt="" />
    </div>
    <div
      id="div"
      style="
        margin-top: 20px;
        font-size: 300px;
        font-weight: bold;
        text-align: center;
      "
    ></div>
  </body>
</html>
